import java.util.Scanner;

/**
 * @author yexiebao
 * @date 2025/5/13
 */
public class GenerateMatrix {
    public static int[][] generateMatrix(int n){
        //1.创建一个二维数组
        int[][] matrix = new int[n][n];
        //2.定义边界值
        int left = 0,right = n-1,top = 0,bottom = n-1;
        //3.要填入的数字
        int num = 1;
        //4.循环
        while(left <= right && top <= bottom){
            //5.循环从左到右
            for (int i =left;i<=right;i++){
                matrix[top][i] = num++;
            }
            //6.上边界下移
            top++;
            //7.循环从上到下
            for(int i =top;i<=bottom;i++){
                matrix[i][right] = num++;
            }
            //8.右边界左移
            right--;
            //9.循环从右到左,但必须先判断
            if(left<=right){
                for (int i = right;i>=left;i--){
                    matrix[bottom][i] = num++;
                }
            }
            //10.下边界上移
            bottom--;
            //11.循环从下到上,但必须先判断
            if(top<=bottom){
                for(int i = bottom;i>=top;i--){
                    matrix[i][left]=num++;
                }
            }
            //12.左边界右移
            left++;
        }
        return matrix;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] matrix = generateMatrix(n);
        for(int i = 0;i < n;i++){
            for(int j = 0;j < n;j++){
                System.out.print(matrix[i][j] + "\t");
            }
            System.out.println();//每打印一行就换行
        }
    }
}